import java.util.Scanner;
public class A9{
	public static void main(String[] agrs){
		//1.设计一个方法用于数组遍历,要求打印出这种:[11,22,33,44,55]
		int[] numbers = {11,22,33,44,55};
		printArr(numbers);
		
		//2.设计一个方法求数组的最大值,并将最大值返回
		int[] numbers1 = {5,8,12,45,53,24};
		int max = printMax(numbers1);
		System.out.println(max);
		
		//3.定义一个方法判断数组中的某一个数是否存在,将结果返回给调用处
		int[] numbers2 = {25,12,41,62,48,26};
		Scanner sc = new Scanner(System.in);
		int digit = sc.nextInt();
		System.out.println(isequal(numbers2,digit));
		
		//4.定义一个方法copyOfRange(int[] arr,int from,int to)
		//功能:将数组arr中从索引from(包含from)开始,到索引to(不包含to)的元素复制到新的数组中,将新数组返回
		int[] numbers3 = {1,2,3,4,5,6,7,8,9,10};
		int from = 2,to = 5;
		int[] numbers4 = copyOfRange(numbers3,from,to);
		for(int i = 0;i < numbers4.length;i++){
			System.out.print(numbers4[i]+" ");
		}
	}
	//1.设计一个方法用于数组遍历,要求打印出这种:[11,22,33,44,55]
	public static void printArr(int[] arr){
		System.out.print('[');
		for(int i = 0;i < arr.length;i++){
			if(i == arr.length-1){
				System.out.print(arr[i]);
			}else{
				System.out.print(arr[i]+",");//注意这个地方不能写','
			}
		}
		System.out.println(']');
	}
	
	//2.设计一个方法求数组的最大值,并将最大值返回
	public static int printMax(int[] arr){
		int max = arr[0];
		for(int i = 1;i < arr.length;i++){
			if(max < arr[i]){
				max = arr[i];
			}
		}
		return max;
	}
	
	//3.定义一个方法判断数组中的某一个数是否存在,将结果返回给调用处
	public static boolean isequal(int[] arr,int number){
		for(int i = 0;i < arr.length;i++){
			if(arr[i] == number){
				return true;
			}
		}
		return false;
	}
	
	//4.定义一个方法copyOfRange(int[] arr,int from,int to)
	//功能:将数组arr中从索引from(包含from)开始,到索引to(不包含to)的元素复制到新的数组中,将新数组返回
	public static int[] copyOfRange(int[] arr,int from,int to){
		int[] numbers4 = new int[to - from];
		for(int i = 0;i < numbers4.length;i++,from++){
			numbers4[i] = arr[from];
		}
		return numbers4;
	}
		
}